草庐IT

asynchronous - Flutter Redux snackbar

全部标签

asynchronous - 如何使用 future 的列表并在 listView 中使用它

我正在尝试获取某个目录中所有文件的列表。我从名为getUserVideos()的future函数中获取文件,如果在函数内部我尝试打印数据,我可以看到结果,但我不能在函数外部使用数据.class_mediaUtentiStateextendsState{varlightBlue=Color.fromRGBO(0,197,205,1.0);var_imagesDir;@overridevoidinitState(){super.initState();getUsersVideos();}ListNames=['Abhishek','John','Robert','Shyam','Sita'

asynchronous - Flutter:使用相同的按钮启动和停止计时器

我有一个秒表,我想要一个按钮来暂停和启动它。我正在为这件事的逻辑而苦苦挣扎。打印到控制台时,bool值卡在false上,不会让我重新单击按钮。秒表.dart:classNewStopWatchextendsStatefulWidget{@override_NewStopWatchStatecreateState()=>new_NewStopWatchState();}class_NewStopWatchStateextendsState{Stopwatchwatch=newStopwatch();Timertimer;boolstartStop=true;StringelapsedTi

asynchronous - 如何使用异步函数异步监听 Firestore 中的值?

我在Flutter中有一个与Firestore通信的异步函数。有一个运行的服务器功能,我的任务完成指示是我使用StreamSubscription收听的标志。StreamSubscription监听代码包装有Future异步函数,但我无法理解如何从StreamSubscription的函数处理程序返回Future。staticFuturelistenToProcess(Stringdoc,Functionfunc){StreamSubscriptionstream=Firestore.instance.collection('requests').document(doc).snaps

asynchronous - 如何在 Flutter 的异步任务中启动异步任务?

有时您有一个异步任务,其中的子任务彼此异步,但有许多同步子任务。例如,今天是清洁日:Futureclean(Stringday)async{boolallIsClean=false;if(day=='sunday'){boolfloorIsClean=await;//Pickupitems,vacuumflor,mopfloor(inthatorder);booldishesAreClean=await;//collectdishes,startdishwasher,emptydishwasher(inthatorder);allIsClean=floorIsClean&&dishes

asynchronous - 如何解决将 Future<dynamic> 实例作为参数传递的错误?

我得到错误:I/flutter(4091):ThefollowingNoSuchMethodErrorwasthrownbuildingBuilder:I/flutter(4091):Class'Future'hasnoinstancemethod'[]'.I/flutter(4091):Receiver:Instanceof'Future'I/flutter(4091):Triedcalling:[]("main")并追溯到:voidupdateUI(dynamicweatherData){setState((){if(weatherData==null){//errorchecki

asynchronous - 如何在 Flutter 的 Firebase 快照上调用 Future?

当我使用StreamBuilder返回一个快照时,我收到一个重复的错误,该错误只持续一两秒,上面写着“在null上调用快照”。我相信我需要让我的快照异步,但我可能完全错了。这是我的代码...child:newStreamBuilder(stream:fb.child('UserVideo/${fUser.uid}').orderByKey().onValue,builder:(BuildContextcontext,AsyncSnapshotevent){if(event.data.snapshot.value==null){returnnewCard(child:newCenter(

asynchronous - Flutter: future 和共同偏好

我有一个名为“retrieveDB”的函数,它使用shared_preferences.dart插件检索数据,我将使用这些数据来决定是否要从Firestore检索什么集合/文档名称。我已经在类的顶部初始化了usersDB和notifDoc=""。FutureretrieveDB()async{SharedPreferencesprefs=awaitSharedPreferences.getInstance();Stringdb=prefs.getString('db');if(db=="MISS"){usersDB="users_miss";notifDoc="notifTokenMI

asynchronous - Flutter 创建一个 Utility 类但无法调用异步函数

我的flutter应用程序创建了一个实用程序类,并希望在不同的文件/页面中使用实用程序类中的函数。但是Utility类的async函数不能被其他文件调用。请帮助解决这个问题。import'package:flutter/material.dart';import'package:connectivity/connectivity.dart';import'dart:async';classUtility{ConnectivityResultconnectivityResult;FuturecheckConnection()async{connectivityResult=await(n

asynchronous - 用于图像哈希的 Flutter 计算函数

hii我正在尝试实现计算功能。我正在尝试使用image_picker插件通过相机点击图像。然后我试图获取图像文件的哈希摘要。由于它是一个非常密集的操作,我正在尝试使用计算功能但无法这样做。这是我到目前为止所做的finalFilepicture=awaitImagePicker.pickImage(source:ImageSource.camera);setState((){_imageFile=picture;});varresult=awaitcompute(generateImageHash(),_imageFile);print(result);这是我试图传递给计算函数的gene

asynchronous - 未处理的异常 : type '_InternalLinkedHashMap<String, dynamic>' is not a subtype of type 'Future<dynamic>'

我收到错误消息:UnhandledException:type'_InternalLinkedHashMap'isnotasubtypeoftype'Future`_LocationScreenState.build.(package:clima/screens/location_screen.dart:71:32)被精确定位的线在里面:FlatButton(onPressed:()async{varweatherData=awaitweather.getLocationWeather();updateUI(weatherData);//weather.getLocationWeath